home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume10 / ptoc / part01 next >
Encoding:
Internet Message Format  |  1987-07-26  |  38.5 KB

  1. Path: uunet!rs
  2. From: rs@uunet.UU.NET (Rich Salz)
  3. Newsgroups: comp.sources.unix
  4. Subject: v10i065:  Pascal to C translator, Part01/12
  5. Message-ID: <704@uunet.UU.NET>
  6. Date: 27 Jul 87 23:01:10 GMT
  7. Organization: UUNET Communications Services, Arlington, VA
  8. Lines: 1589
  9. Approved: rs@uunet.UU.NET
  10.  
  11. Submitted-by: Per Bergsten <mcvax!enea!chalmers!holtec!perb>
  12. Posting-number: Volume 10, Issue 65
  13. Archive-name: ptoc/Part01
  14.  
  15. [  This program translates monolithic Pascal programs into monolithic
  16.    C programs.  To compile either the .c or the .p version, you will
  17.    first have to join all the ptc.c.[1-7] or ptc.p.[1-5] parts together
  18.    first.  The manpage and ptc.doc will also be usefl.  --r$  ]
  19.  
  20. #! /bin/sh
  21. # This is a shell archive.  Remove anything before this line, then unpack
  22. # it by saving it into a file and typing "sh file".  To overwrite existing
  23. # files, type "sh file -c".  You can also feed this as standard input via
  24. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  25. # will see the following message at the end:
  26. #        "End of archive 1 (of 12)."
  27. # Contents:  MANIFEST README makefile ptc.c.7 ptc.man
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  31. else
  32. echo shar: Extracting \"'MANIFEST'\" \(594 characters\)
  33. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  34. X   File Name        Archive #    Description
  35. X-----------------------------------------------------------
  36. X MANIFEST                  1    This shipping list
  37. X README                    1    
  38. X makefile                  1    
  39. X ptc.c.1                   3    
  40. X ptc.c.2                   4    
  41. X ptc.c.3                   2    
  42. X ptc.c.4                   6    
  43. X ptc.c.5                   7    
  44. X ptc.c.6                   8    
  45. X ptc.c.7                   1    
  46. X ptc.man                   1    
  47. X ptc.p.1                  12    
  48. X ptc.p.2                  10    
  49. X ptc.p.3                   9    
  50. X ptc.p.4                  11    
  51. X ptoc.doc                  5    
  52. END_OF_FILE
  53. if test 594 -ne `wc -c <'MANIFEST'`; then
  54.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  55. fi
  56. # end of 'MANIFEST'
  57. fi
  58. if test -f 'README' -a "${1}" != "-c" ; then 
  59.   echo shar: Will not clobber existing file \"'README'\"
  60. else
  61. echo shar: Extracting \"'README'\" \(1473 characters\)
  62. sed "s/^X//" >'README' <<'END_OF_FILE'
  63. XSetting up the Pascal to C translator.
  64. X
  65. XThe translator is a single huge Pascal program. If you are working on a UNIX
  66. Xsystem that has a Pascal compiler what you need to do is to unpack and
  67. Xconcatenate the four parts forming the translator sourcecode, "ptc.p",
  68. Xunpack the "makefile", say "make ptc" and take a break.
  69. X
  70. XIf you are on a non-UNIX system proceed with discretion.
  71. X
  72. XIf compilation fails due to the program size you may consider attacking the C
  73. Xversion, "ptc.c", if this too is too large to compile you may as well give up.
  74. XIf it fails to compile or run for other reasons you may try to contact me.
  75. X
  76. XWhen/if the ptc program is created you may try saying "make tests", this should
  77. Xnot produce any output at all. If it does it means that ptc obtained from ptc.p
  78. Xdiffered in behaviour from cptc obtained from ptc.c obtained from ptc.p. In that
  79. Xcase your Pascal and/or C compilers depart seriously from the ones availible to
  80. Xthe author, this may imply a bug in ptc.
  81. X
  82. XRead the section "Tuning" in the implementation notes and do what you believe
  83. Xis appropriate for your installation; recompile and install binary and man-page
  84. Xas necessary.
  85. X
  86. XSend vitriolic comments to /dev/null;
  87. Xchecks, constructive critisism and bug-reports to the address below.
  88. X
  89. X
  90. XSincerely,
  91. X
  92. X    Per Bergsten
  93. X
  94. XEmail:    perb%holtec.uucp@chalmers.csnet
  95. X    ... mcvax!enea!chalmers!holtec!perb
  96. Xaka:    bergsten@chalmers
  97. X
  98. XSmail:    Holistic Technology AB
  99. X    Grona Gatan 59
  100. X    414 54 Gothenburg
  101. X    Sweden
  102. X
  103. XFax:    +46 31 247456
  104. X
  105. END_OF_FILE
  106. if test 1473 -ne `wc -c <'README'`; then
  107.     echo shar: \"'README'\" unpacked with wrong size!
  108. fi
  109. # end of 'README'
  110. fi
  111. if test -f 'makefile' -a "${1}" != "-c" ; then 
  112.   echo shar: Will not clobber existing file \"'makefile'\"
  113. else
  114. echo shar: Extracting \"'makefile'\" \(974 characters\)
  115. sed "s/^X//" >'makefile' <<'END_OF_FILE'
  116. X#
  117. X#    @(#)Makefile    1.5 Date 87/05/09
  118. X#
  119. XCFLAGS    = -O
  120. XPFLAGS    = -O
  121. XFILES    = makefile ptc.p ptc.c ptc doc.ms doc.out ptc.man man.out
  122. XPAGELEN    = -rP70
  123. XDEV    = /dev/rst8
  124. XBLK    = 126
  125. X
  126. X.DEFAULT:
  127. X    $(GET) -p -s SCCS/s.$@ > $@
  128. X
  129. X# default version
  130. XS    = p
  131. Xptc:        ptc.$S
  132. X        $Sc -O -o ptc ptc.$S
  133. X
  134. X# translated version
  135. Xcptc:        cptc.c
  136. X        cc -O -o cptc cptc.c
  137. X
  138. Xcptc.c:        ptc.p ptc
  139. X        ptc < ptc.p > cptc.c
  140. X
  141. Xtests:    test0
  142. X
  143. X
  144. X#
  145. X#    Perform a simple test translating the source with the compiled
  146. X#    translator and the compairing its own source against its
  147. X#    translation of its own source. They should be exactly equal.
  148. X#
  149. Xtest0:    ptc cptc.c cptc FRC
  150. X    cptc < ptc.p > tmp.c
  151. X    cmp cptc.c tmp.c && rm tmp.c
  152. X
  153. X
  154. XFRC:
  155. X
  156. X#
  157. X#    Documentation.
  158. X#
  159. Xdoc.out:    doc.ms
  160. X        tbl doc.ms | nroff -T$(TERM) $(PAGELEN) -ms - > doc.out
  161. X
  162. Xman.out:    ptc.man
  163. X        nroff -T$(TERM) $(PAGELEN) -man ptc.man > man.out
  164. X
  165. X
  166. X#
  167. X#    Maintenance
  168. X#
  169. Xcleanup:
  170. X    rm -f cptc cptc.c tmp.c out
  171. X
  172. Xclean::    cleanup
  173. X
  174. X
  175. Xclobber:: cleanup
  176. X
  177. X
  178. Xtape:    $(FILES)
  179. X    tar cvfb $(DEV) $(BLK) $(FILES)
  180. END_OF_FILE
  181. if test 974 -ne `wc -c <'makefile'`; then
  182.     echo shar: \"'makefile'\" unpacked with wrong size!
  183. fi
  184. # end of 'makefile'
  185. fi
  186. if test -f 'ptc.c.7' -a "${1}" != "-c" ; then 
  187.   echo shar: Will not clobber existing file \"'ptc.c.7'\"
  188. else
  189. echo shar: Extracting \"'ptc.c.7'\" \(28856 characters\)
  190. sed "s/^X//" >'ptc.c.7' <<'END_OF_FILE'
  191. X void
  192. Xdefmach(lo, hi, str)
  193. X    integer    lo, hi;
  194. X    machdefstr    str;
  195. X{
  196. X    register toknidx    i;
  197. X    toknbuf    w;
  198. X
  199. X    {   register int    _j, _i = 1 - 1;
  200. X        for (_j = 0; _j < 16; )
  201. X        w.A[_i++] = str.A[_j++];
  202. X    }
  203. X    if (w.A[machdeflen - 1] != space)
  204. X        error(ebadmach);
  205. X    {
  206. X        toknidx    B74 = machdeflen - 1,
  207. X            B75 = 1;
  208. X
  209. X        if (B74 >= B75)
  210. X            for (i = B74; ; i--) {
  211. X                if (w.A[i - 1] != space) {
  212. X                    w.A[i + 1 - 1] = null;
  213. X                    goto L999;
  214. X                }
  215. X                if (i == B75) break;
  216. X            }
  217. X    }
  218. X    error(ebadmach);
  219. XL999:
  220. X    if (nmachdefs >= maxmachdefs)
  221. X        error(emanymachs);
  222. X    nmachdefs = nmachdefs + 1;
  223. X    {
  224. X        register struct S193 *W76 = &machdefs.A[nmachdefs - 1];
  225. X
  226. X        W76->lolim = lo;
  227. X        W76->hilim = hi;
  228. X        W76->typstr = savestr(&w);
  229. X    }
  230. X}
  231. X
  232. X void
  233. Xinitstrstore()
  234. X{
  235. X    register strbcnt    i;
  236. X
  237. X    {
  238. X        strbcnt    B77 = 1,
  239. X            B78 = maxblkcnt;
  240. X
  241. X        if (B77 <= B78)
  242. X            for (i = B77; ; i++) {
  243. X                strstor.A[i] = (strblk *)NIL;
  244. X                if (i == B78) break;
  245. X            }
  246. X    }
  247. X    strstor.A[0] = (strblk *)malloc((unsigned)(sizeof(*strstor.A[0])));
  248. X    strstor.A[0]->A[0] = null;
  249. X    strfree = 1;
  250. X    strleft = maxstrblk;
  251. X}
  252. X
  253. X
  254. X void
  255. Xinitialize()
  256. X{
  257. X    register hashtyp    s;
  258. X    register pretyps    t;
  259. X    register predefs    d;
  260. X
  261. X    lineno = 1;
  262. X    colno = 0;
  263. X    initstrstore();
  264. X    setlst = (struct S61 *)NIL;
  265. X    setcnt = 0;
  266. X    (void)strncpy(hexdig.A, "0123456789ABCDEF", sizeof(hexdig.A));
  267. X    symtab = (struct S60 *)NIL;
  268. X    statlvl = 0;
  269. X    maxlevel = -1;
  270. X    enterscope((declptr)NIL);
  271. X    varno = 0;
  272. X    usenilp = false;
  273. X    usesets = false;
  274. X    useunion = false;
  275. X    usediff = false;
  276. X    usemksub = false;
  277. X    useintr = false;
  278. X    usesge = false;
  279. X    usesle = false;
  280. X    usesne = false;
  281. X    useseq = false;
  282. X    usememb = false;
  283. X    useins = false;
  284. X    usescpy = false;
  285. X    usefopn = false;
  286. X    usescan = false;
  287. X    usegetl = false;
  288. X    usecase = false;
  289. X    usejmps = false;
  290. X    usebool = false;
  291. X    usecomp = false;
  292. X    usemax = false;
  293. X    {
  294. X        hashtyp    B79 = 0,
  295. X            B80 = hashmax;
  296. X
  297. X        if (B79 <= B80)
  298. X            for (s = B79; ; s++) {
  299. X                idtab.A[s] = (struct S59 *)NIL;
  300. X                if (s == B80) break;
  301. X            }
  302. X    }
  303. X    {
  304. X        predefs    B81 = dabs,
  305. X            B82 = dztring;
  306. X
  307. X        if ((int)(B81) <= (int)(B82))
  308. X            for (d = B81; ; d = (predefs)((int)(d)+1)) {
  309. X                deftab.A[(int)(d)] = (struct S61 *)NIL;
  310. X                defnams.A[(int)(d)] = (struct S62 *)NIL;
  311. X                if (d == B82) break;
  312. X            }
  313. X    }
  314. X    defkey(sand, *((keyword *)"and       "));
  315. X    defkey(sarray, *((keyword *)"array     "));
  316. X    defkey(sbegin, *((keyword *)"begin     "));
  317. X    defkey(scase, *((keyword *)"case      "));
  318. X    defkey(sconst, *((keyword *)"const     "));
  319. X    defkey(sdiv, *((keyword *)"div       "));
  320. X    defkey(sdo, *((keyword *)"do        "));
  321. X    defkey(sdownto, *((keyword *)"downto    "));
  322. X    defkey(selse, *((keyword *)"else      "));
  323. X    defkey(send, *((keyword *)"end       "));
  324. X    defkey(sextern, *((keyword *)externsym));
  325. X    defkey(sfile, *((keyword *)"file      "));
  326. X    defkey(sfor, *((keyword *)"for       "));
  327. X    defkey(sforward, *((keyword *)"forward   "));
  328. X    defkey(sfunc, *((keyword *)"function  "));
  329. X    defkey(sgoto, *((keyword *)"goto      "));
  330. X    defkey(sif, *((keyword *)"if        "));
  331. X    defkey(sinn, *((keyword *)"in        "));
  332. X    defkey(slabel, *((keyword *)"label     "));
  333. X    defkey(smod, *((keyword *)"mod       "));
  334. X    defkey(snil, *((keyword *)"nil       "));
  335. X    defkey(snot, *((keyword *)"not       "));
  336. X    defkey(sof, *((keyword *)"of        "));
  337. X    defkey(sor, *((keyword *)"or        "));
  338. X    defkey(sother, *((keyword *)othersym));
  339. X    defkey(spacked, *((keyword *)"packed    "));
  340. X    defkey(sproc, *((keyword *)"procedure "));
  341. X    defkey(spgm, *((keyword *)"program   "));
  342. X    defkey(srecord, *((keyword *)"record    "));
  343. X    defkey(srepeat, *((keyword *)"repeat    "));
  344. X    defkey(sset, *((keyword *)"set       "));
  345. X    defkey(sthen, *((keyword *)"then      "));
  346. X    defkey(sto, *((keyword *)"to        "));
  347. X    defkey(stype, *((keyword *)"type      "));
  348. X    defkey(suntil, *((keyword *)"until     "));
  349. X    defkey(svar, *((keyword *)"var       "));
  350. X    defkey(swhile, *((keyword *)"while     "));
  351. X    defkey(swith, *((keyword *)"with      "));
  352. X    defkey(seof, *((keyword *)dummysym));
  353. X    cprio.A[(int)(nformat) - (int)(nassign)] = 0;
  354. X    cprio.A[(int)(nrange) - (int)(nassign)] = 0;
  355. X    cprio.A[(int)(nin) - (int)(nassign)] = 0;
  356. X    cprio.A[(int)(nset) - (int)(nassign)] = 0;
  357. X    cprio.A[(int)(nassign) - (int)(nassign)] = 0;
  358. X    cprio.A[(int)(nor) - (int)(nassign)] = 1;
  359. X    cprio.A[(int)(nand) - (int)(nassign)] = 2;
  360. X    cprio.A[(int)(neq) - (int)(nassign)] = 3;
  361. X    cprio.A[(int)(nne) - (int)(nassign)] = 3;
  362. X    cprio.A[(int)(nlt) - (int)(nassign)] = 3;
  363. X    cprio.A[(int)(nle) - (int)(nassign)] = 3;
  364. X    cprio.A[(int)(ngt) - (int)(nassign)] = 3;
  365. X    cprio.A[(int)(nge) - (int)(nassign)] = 3;
  366. X    cprio.A[(int)(nplus) - (int)(nassign)] = 4;
  367. X    cprio.A[(int)(nminus) - (int)(nassign)] = 4;
  368. X    cprio.A[(int)(nmul) - (int)(nassign)] = 5;
  369. X    cprio.A[(int)(ndiv) - (int)(nassign)] = 5;
  370. X    cprio.A[(int)(nmod) - (int)(nassign)] = 5;
  371. X    cprio.A[(int)(nquot) - (int)(nassign)] = 5;
  372. X    cprio.A[(int)(nnot) - (int)(nassign)] = 6;
  373. X    cprio.A[(int)(numinus) - (int)(nassign)] = 6;
  374. X    cprio.A[(int)(nuplus) - (int)(nassign)] = 7;
  375. X    cprio.A[(int)(nindex) - (int)(nassign)] = 7;
  376. X    cprio.A[(int)(nselect) - (int)(nassign)] = 7;
  377. X    cprio.A[(int)(nderef) - (int)(nassign)] = 7;
  378. X    cprio.A[(int)(ncall) - (int)(nassign)] = 7;
  379. X    cprio.A[(int)(nid) - (int)(nassign)] = 7;
  380. X    cprio.A[(int)(nchar) - (int)(nassign)] = 7;
  381. X    cprio.A[(int)(ninteger) - (int)(nassign)] = 7;
  382. X    cprio.A[(int)(nreal) - (int)(nassign)] = 7;
  383. X    cprio.A[(int)(nstring) - (int)(nassign)] = 7;
  384. X    cprio.A[(int)(nnil) - (int)(nassign)] = 7;
  385. X    pprio.A[(int)(nassign) - (int)(nassign)] = 0;
  386. X    pprio.A[(int)(nformat) - (int)(nassign)] = 0;
  387. X    pprio.A[(int)(nrange) - (int)(nassign)] = 1;
  388. X    pprio.A[(int)(nin) - (int)(nassign)] = 1;
  389. X    pprio.A[(int)(neq) - (int)(nassign)] = 1;
  390. X    pprio.A[(int)(nne) - (int)(nassign)] = 1;
  391. X    pprio.A[(int)(nlt) - (int)(nassign)] = 1;
  392. X    pprio.A[(int)(nle) - (int)(nassign)] = 1;
  393. X    pprio.A[(int)(ngt) - (int)(nassign)] = 1;
  394. X    pprio.A[(int)(nge) - (int)(nassign)] = 1;
  395. X    pprio.A[(int)(nor) - (int)(nassign)] = 2;
  396. X    pprio.A[(int)(nplus) - (int)(nassign)] = 2;
  397. X    pprio.A[(int)(nminus) - (int)(nassign)] = 2;
  398. X    pprio.A[(int)(nand) - (int)(nassign)] = 3;
  399. X    pprio.A[(int)(nmul) - (int)(nassign)] = 3;
  400. X    pprio.A[(int)(ndiv) - (int)(nassign)] = 3;
  401. X    pprio.A[(int)(nmod) - (int)(nassign)] = 3;
  402. X    pprio.A[(int)(nquot) - (int)(nassign)] = 3;
  403. X    pprio.A[(int)(nnot) - (int)(nassign)] = 4;
  404. X    pprio.A[(int)(numinus) - (int)(nassign)] = 4;
  405. X    pprio.A[(int)(nuplus) - (int)(nassign)] = 5;
  406. X    pprio.A[(int)(nset) - (int)(nassign)] = 6;
  407. X    pprio.A[(int)(nindex) - (int)(nassign)] = 6;
  408. X    pprio.A[(int)(nselect) - (int)(nassign)] = 6;
  409. X    pprio.A[(int)(nderef) - (int)(nassign)] = 6;
  410. X    pprio.A[(int)(ncall) - (int)(nassign)] = 6;
  411. X    pprio.A[(int)(nid) - (int)(nassign)] = 6;
  412. X    pprio.A[(int)(nchar) - (int)(nassign)] = 6;
  413. X    pprio.A[(int)(ninteger) - (int)(nassign)] = 6;
  414. X    pprio.A[(int)(nreal) - (int)(nassign)] = 6;
  415. X    pprio.A[(int)(nstring) - (int)(nassign)] = 6;
  416. X    pprio.A[(int)(nnil) - (int)(nassign)] = 6;
  417. X    defname(cabort, *((keyword *)"abort     "));
  418. X    defname(cbreak, *((keyword *)"break     "));
  419. X    defname(ccontinue, *((keyword *)"continue  "));
  420. X    defname(cdefine, *((keyword *)"define    "));
  421. X    defname(cdefault, *((keyword *)"default   "));
  422. X    defname(cdouble, *((keyword *)"double    "));
  423. X    defname(cedata, *((keyword *)"edata     "));
  424. X    defname(cenum, *((keyword *)"enum      "));
  425. X    defname(cetext, *((keyword *)"etext     "));
  426. X    defname(cextern, *((keyword *)"extern    "));
  427. X    defname(cfclose, *((keyword *)"fclose    "));
  428. X    defname(cfflush, *((keyword *)"fflush    "));
  429. X    defname(cfgetc, *((keyword *)"fgetc     "));
  430. X    defname(cfloat, *((keyword *)"float     "));
  431. X    defname(cfloor, *((keyword *)"floor     "));
  432. X    defname(cfprintf, *((keyword *)"fprintf   "));
  433. X    defname(cfputc, *((keyword *)"fputc     "));
  434. X    defname(cfread, *((keyword *)"fread     "));
  435. X    defname(cfscanf, *((keyword *)"fscanf    "));
  436. X    defname(cfwrite, *((keyword *)"fwrite    "));
  437. X    defname(cgetc, *((keyword *)"getc      "));
  438. X    defname(cgetpid, *((keyword *)"getpid    "));
  439. X    defname(cint, *((keyword *)"int       "));
  440. X    defname(cinclude, *((keyword *)"include   "));
  441. X    defname(clong, *((keyword *)"long      "));
  442. X    defname(clog, *((keyword *)"log       "));
  443. X    defname(cmain, *((keyword *)"main      "));
  444. X    defname(cmalloc, *((keyword *)"malloc    "));
  445. X    defname(cprintf, *((keyword *)"printf    "));
  446. X    defname(cpower, *((keyword *)"pow       "));
  447. X    defname(cputc, *((keyword *)"putc      "));
  448. X    defname(cread, *((keyword *)"read      "));
  449. X    defname(creturn, *((keyword *)"return    "));
  450. X    defname(cregister, *((keyword *)"register  "));
  451. X    defname(crewind, *((keyword *)"rewind    "));
  452. X    defname(cscanf, *((keyword *)"scanf     "));
  453. X    defname(csetbits, *((keyword *)"setbits   "));
  454. X    defname(csetword, *((keyword *)"setword   "));
  455. X    defname(csetptr, *((keyword *)"setptr    "));
  456. X    defname(cshort, *((keyword *)"short     "));
  457. X    defname(csigned, *((keyword *)"signed    "));
  458. X    defname(csizeof, *((keyword *)"sizeof    "));
  459. X    defname(csprintf, *((keyword *)"sprintf   "));
  460. X    defname(cstatic, *((keyword *)"static    "));
  461. X    defname(cstdin, *((keyword *)"stdin     "));
  462. X    defname(cstdout, *((keyword *)"stdout    "));
  463. X    defname(cstderr, *((keyword *)"stderr    "));
  464. X    defname(cstrncmp, *((keyword *)"strncmp   "));
  465. X    defname(cstrncpy, *((keyword *)"strncpy   "));
  466. X    defname(cstruct, *((keyword *)"struct    "));
  467. X    defname(cswitch, *((keyword *)"switch    "));
  468. X    defname(ctypedef, *((keyword *)"typedef   "));
  469. X    defname(cundef, *((keyword *)"undef     "));
  470. X    defname(cungetc, *((keyword *)"ungetc    "));
  471. X    defname(cunion, *((keyword *)"union     "));
  472. X    defname(cunlink, *((keyword *)"unlink    "));
  473. X    defname(cunsigned, *((keyword *)"unsigned  "));
  474. X    defname(cwrite, *((keyword *)"write     "));
  475. X    defid(nfunc, dabs, *((keyword *)"abs       "));
  476. X    defid(nfunc, darctan, *((keyword *)"arctan    "));
  477. X    defid(nvar, dargc, *((keyword *)"argc      "));
  478. X    defid(nproc, dargv, *((keyword *)"argv      "));
  479. X    defid(nscalar, dboolean, *((keyword *)"boolean   "));
  480. X    defid(ntype, dchar, *((keyword *)"char      "));
  481. X    defid(nfunc, dchr, *((keyword *)"chr       "));
  482. X    defid(nproc, dclose, *((keyword *)"close     "));
  483. X    defid(nfunc, dcos, *((keyword *)"cos       "));
  484. X    defid(nproc, ddispose, *((keyword *)"dispose   "));
  485. X    defid(nid, dfalse, *((keyword *)"false     "));
  486. X    defid(nfunc, deof, *((keyword *)"eof       "));
  487. X    defid(nfunc, deoln, *((keyword *)"eoln      "));
  488. X    defid(nproc, dexit, *((keyword *)"exit      "));
  489. X    defid(nfunc, dexp, *((keyword *)"exp       "));
  490. X    defid(nproc, dflush, *((keyword *)"flush     "));
  491. X    defid(nproc, dget, *((keyword *)"get       "));
  492. X    defid(nproc, dhalt, *((keyword *)"halt      "));
  493. X    defid(nvar, dinput, *((keyword *)"input     "));
  494. X    defid(ntype, dinteger, *((keyword *)"integer   "));
  495. X    defid(nfunc, dln, *((keyword *)"ln        "));
  496. X    defid(nconst, dmaxint, *((keyword *)"maxint    "));
  497. X    defid(nproc, dmessage, *((keyword *)"message   "));
  498. X    defid(nproc, dnew, *((keyword *)"new       "));
  499. X    defid(nfunc, dodd, *((keyword *)"odd       "));
  500. X    defid(nfunc, dord, *((keyword *)"ord       "));
  501. X    defid(nvar, doutput, *((keyword *)"output    "));
  502. X    defid(nproc, dpack, *((keyword *)"pack      "));
  503. X    defid(nproc, dpage, *((keyword *)"page      "));
  504. X    defid(nfunc, dpred, *((keyword *)"pred      "));
  505. X    defid(nproc, dput, *((keyword *)"put       "));
  506. X    defid(nproc, dread, *((keyword *)"read      "));
  507. X    defid(nproc, dreadln, *((keyword *)"readln    "));
  508. X    defid(ntype, dreal, *((keyword *)"real      "));
  509. X    defid(nproc, dreset, *((keyword *)"reset     "));
  510. X    defid(nproc, drewrite, *((keyword *)"rewrite   "));
  511. X    defid(nfunc, dround, *((keyword *)"round     "));
  512. X    defid(nfunc, dsin, *((keyword *)"sin       "));
  513. X    defid(nfunc, dsqr, *((keyword *)"sqr       "));
  514. X    defid(nfunc, dsqrt, *((keyword *)"sqrt      "));
  515. X    defid(nfunc, dsucc, *((keyword *)"succ      "));
  516. X    defid(ntype, dtext, *((keyword *)"text      "));
  517. X    defid(nid, dtrue, *((keyword *)"true      "));
  518. X    defid(nfunc, dtrunc, *((keyword *)"trunc     "));
  519. X    defid(nfunc, dtan, *((keyword *)"tan       "));
  520. X    defid(nproc, dunpack, *((keyword *)"unpack    "));
  521. X    defid(nproc, dwrite, *((keyword *)"write     "));
  522. X    defid(nproc, dwriteln, *((keyword *)"writeln   "));
  523. X    defid(nfield, dzinit, *((keyword *)"$nit      "));
  524. X    defid(ntype, dztring, *((keyword *)"$ztring   "));
  525. X    deftab.A[(int)(dboolean)]->U.V14.tbind->U.V17.tscalid = deftab.A[(int)(dfalse)];
  526. X    deftab.A[(int)(dfalse)]->tnext = deftab.A[(int)(dtrue)];
  527. X    currsym.st = sinteger;
  528. X    currsym.U.V3.vint = maxint;
  529. X    deftab.A[(int)(dmaxint)]->U.V14.tbind = mklit();
  530. X    deftab.A[(int)(dargc)]->U.V14.tbind = deftab.A[(int)(dinteger)]->U.V14.tbind;
  531. X    deftab.A[(int)(dinput)]->U.V14.tbind = deftab.A[(int)(dtext)]->U.V14.tbind;
  532. X    deftab.A[(int)(doutput)]->U.V14.tbind = deftab.A[(int)(dtext)]->U.V14.tbind;
  533. X    {
  534. X        pretyps    B83 = tnone,
  535. X            B84 = terror;
  536. X
  537. X        if ((int)(B83) <= (int)(B84))
  538. X            for (t = B83; ; t = (pretyps)((int)(t)+1)) {
  539. X                switch (t) {
  540. X                  case tboolean:
  541. X                    typnods.A[(int)(t)] = deftab.A[(int)(dboolean)];
  542. X                    break ;
  543. X                  case tchar:
  544. X                    typnods.A[(int)(t)] = deftab.A[(int)(dchar)]->U.V14.tbind;
  545. X                    break ;
  546. X                  case tinteger:
  547. X                    typnods.A[(int)(t)] = deftab.A[(int)(dinteger)]->U.V14.tbind;
  548. X                    break ;
  549. X                  case treal:
  550. X                    typnods.A[(int)(t)] = deftab.A[(int)(dreal)]->U.V14.tbind;
  551. X                    break ;
  552. X                  case ttext:
  553. X                    typnods.A[(int)(t)] = deftab.A[(int)(dtext)]->U.V14.tbind;
  554. X                    break ;
  555. X                  case tstring:
  556. X                    typnods.A[(int)(t)] = deftab.A[(int)(dztring)]->U.V14.tbind;
  557. X                    break ;
  558. X                  case tnil:  case tset:  case tpoly:  case tnone:
  559. X                    typnods.A[(int)(t)] = mknode(npredef);
  560. X                    break ;
  561. X                  case terror:
  562. X                    break ;
  563. X                  default:
  564. X                    Caseerror(Line);
  565. X                }
  566. X                if (Member((unsigned)(t), Conset[163]))
  567. X                    typnods.A[(int)(t)]->U.V12.tobtyp = t;
  568. X                if (t == B84) break;
  569. X            }
  570. X    }
  571. X    fixinit(defnams.A[(int)(dzinit)]->U.V6.lid->istr);
  572. X    deftab.A[(int)(dzinit)]->U.V14.tbind = deftab.A[(int)(dinteger)]->U.V14.tbind;
  573. X    {
  574. X        predefs    B85 = dabs,
  575. X            B86 = dztring;
  576. X
  577. X        if ((int)(B85) <= (int)(B86))
  578. X            for (d = B85; ; d = (predefs)((int)(d)+1)) {
  579. X                linkup((treeptr)NIL, deftab.A[(int)(d)]);
  580. X                if (d == B86) break;
  581. X            }
  582. X    }
  583. X    deftab.A[(int)(dchr)]->U.V13.tfuntyp = typnods.A[(int)(tchar)];
  584. X    deftab.A[(int)(deof)]->U.V13.tfuntyp = typnods.A[(int)(tboolean)];
  585. X    deftab.A[(int)(deoln)]->U.V13.tfuntyp = typnods.A[(int)(tboolean)];
  586. X    deftab.A[(int)(dodd)]->U.V13.tfuntyp = typnods.A[(int)(tboolean)];
  587. X    deftab.A[(int)(dord)]->U.V13.tfuntyp = typnods.A[(int)(tinteger)];
  588. X    deftab.A[(int)(dround)]->U.V13.tfuntyp = typnods.A[(int)(tinteger)];
  589. X    deftab.A[(int)(dtrunc)]->U.V13.tfuntyp = typnods.A[(int)(tinteger)];
  590. X    deftab.A[(int)(darctan)]->U.V13.tfuntyp = typnods.A[(int)(treal)];
  591. X    deftab.A[(int)(dcos)]->U.V13.tfuntyp = typnods.A[(int)(treal)];
  592. X    deftab.A[(int)(dsin)]->U.V13.tfuntyp = typnods.A[(int)(treal)];
  593. X    deftab.A[(int)(dtan)]->U.V13.tfuntyp = typnods.A[(int)(treal)];
  594. X    deftab.A[(int)(dsqrt)]->U.V13.tfuntyp = typnods.A[(int)(treal)];
  595. X    deftab.A[(int)(dexp)]->U.V13.tfuntyp = typnods.A[(int)(treal)];
  596. X    deftab.A[(int)(dln)]->U.V13.tfuntyp = typnods.A[(int)(treal)];
  597. X    deftab.A[(int)(dsqr)]->U.V13.tfuntyp = typnods.A[(int)(tpoly)];
  598. X    deftab.A[(int)(dabs)]->U.V13.tfuntyp = typnods.A[(int)(tpoly)];
  599. X    deftab.A[(int)(dpred)]->U.V13.tfuntyp = typnods.A[(int)(tpoly)];
  600. X    deftab.A[(int)(dsucc)]->U.V13.tfuntyp = typnods.A[(int)(tpoly)];
  601. X    deftab.A[(int)(dargv)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
  602. X    deftab.A[(int)(ddispose)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
  603. X    deftab.A[(int)(dexit)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
  604. X    deftab.A[(int)(dget)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
  605. X    deftab.A[(int)(dhalt)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
  606. X    deftab.A[(int)(dnew)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
  607. X    deftab.A[(int)(dpack)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
  608. X    deftab.A[(int)(dput)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
  609. X    deftab.A[(int)(dread)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
  610. X    deftab.A[(int)(dreadln)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
  611. X    deftab.A[(int)(dreset)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
  612. X    deftab.A[(int)(drewrite)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
  613. X    deftab.A[(int)(dwrite)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
  614. X    deftab.A[(int)(dwriteln)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
  615. X    deftab.A[(int)(dmessage)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
  616. X    deftab.A[(int)(dunpack)]->U.V13.tfuntyp = typnods.A[(int)(tnone)];
  617. X    nmachdefs = 0;
  618. X    defmach(0, 255, *((machdefstr *)"unsigned char   "));
  619. X    defmach(-128, 127, *((machdefstr *)"char            "));
  620. X    defmach(0, 65535, *((machdefstr *)"unsigned short  "));
  621. X    defmach(-32768, 32767, *((machdefstr *)"short           "));
  622. X    defmach(-2147483647, 2147483647, *((machdefstr *)"long            "));
  623. X}
  624. X
  625. Xextern void exit();
  626. X
  627. X void
  628. Xerror(m)
  629. X    errors    m;
  630. X{
  631. X    prtmsg(m);
  632. X    exit(1);
  633. X    longjmp(J[0].jb, 9999);
  634. X}
  635. X
  636. X void
  637. Xfatal(m)
  638. X    errors    m;
  639. X{
  640. X    prtmsg(m);
  641. X    abort();
  642. X}
  643. X
  644. X/*
  645. X**    Start of program code
  646. X*/
  647. Xmain()
  648. X{
  649. X    if (setjmp(J[0].jb))
  650. X    goto L9999;
  651. X    initialize();
  652. X    if (echo)
  653. X        (void)fprintf(output.fp, "# ifdef PASCAL\n"), Putl(output, 1);
  654. X    parse();
  655. X    if (echo)
  656. X        (void)fprintf(output.fp, "# else\n"), Putl(output, 1);
  657. X    lineno = 0;
  658. X    lastline = 0;
  659. X    transform();
  660. X    emit();
  661. X    if (echo)
  662. X        (void)fprintf(output.fp, "# endif\n"), Putl(output, 1);
  663. XL9999:
  664. X    ;
  665. X    exit(0);
  666. X}
  667. X/*
  668. X**    End of program code
  669. X*/
  670. Xstatic setword    Q0[] = {
  671. X    1,
  672. X    0x03FD
  673. X};
  674. Xstatic setword    Q1[] = {
  675. X    1,
  676. X    0x004C
  677. X};
  678. Xstatic setword    Q2[] = {
  679. X    1,
  680. X    0x0000
  681. X};
  682. Xstatic setword    Q3[] = {
  683. X    2,
  684. X    0x000E,    0x5210
  685. X};
  686. Xstatic setword    Q4[] = {
  687. X    2,
  688. X    0x000E,    0x1210
  689. X};
  690. Xstatic setword    Q5[] = {
  691. X    1,
  692. X    0x0C00
  693. X};
  694. Xstatic setword    Q6[] = {
  695. X    1,
  696. X    0x000C
  697. X};
  698. Xstatic setword    Q7[] = {
  699. X    2,
  700. X    0x000E,    0x0210
  701. X};
  702. Xstatic setword    Q8[] = {
  703. X    3,
  704. X    0x0000,    0x0000,    0x0060
  705. X};
  706. Xstatic setword    Q9[] = {
  707. X    4,
  708. X    0x0002,    0x0000,    0x0064,    0x0800
  709. X};
  710. Xstatic setword    Q10[] = {
  711. X    1,
  712. X    0x0C00
  713. X};
  714. Xstatic setword    Q11[] = {
  715. X    1,
  716. X    0x000C
  717. X};
  718. Xstatic setword    Q12[] = {
  719. X    4,
  720. X    0x0000,    0x0000,    0x4FF0,    0x0008
  721. X};
  722. Xstatic setword    Q13[] = {
  723. X    3,
  724. X    0x0000,    0x0000,    0x0780
  725. X};
  726. Xstatic setword    Q14[] = {
  727. X    3,
  728. X    0x0000,    0x0000,    0x0780
  729. X};
  730. Xstatic setword    Q15[] = {
  731. X    5,
  732. X    0x0000,    0x0001,    0x0000,    0x0000,    0x0001
  733. X};
  734. Xstatic setword    Q16[] = {
  735. X    3,
  736. X    0x0000,    0x0000,    0x07E0
  737. X};
  738. Xstatic setword    Q17[] = {
  739. X    3,
  740. X    0x0000,    0x0000,    0xB000
  741. X};
  742. Xstatic setword    Q18[] = {
  743. X    4,
  744. X    0x0000,    0x0008,    0x0000,    0x0040
  745. X};
  746. Xstatic setword    Q19[] = {
  747. X    3,
  748. X    0x0000,    0x0000,    0xB560
  749. X};
  750. Xstatic setword    Q20[] = {
  751. X    4,
  752. X    0x0000,    0x0000,    0x4FF0,    0x0008
  753. X};
  754. Xstatic setword    Q21[] = {
  755. X    1,
  756. X    0x0C00
  757. X};
  758. Xstatic setword    Q22[] = {
  759. X    4,
  760. X    0x0000,    0x0000,    0x0000,    0x1700
  761. X};
  762. Xstatic setword    Q23[] = {
  763. X    2,
  764. X    0x0000,    0x0003
  765. X};
  766. Xstatic setword    Q24[] = {
  767. X    4,
  768. X    0x0000,    0x0000,    0x0000,    0x1700
  769. X};
  770. Xstatic setword    Q25[] = {
  771. X    3,
  772. X    0x0000,    0x0040,    0x4000
  773. X};
  774. Xstatic setword    Q26[] = {
  775. X    1,
  776. X    0x000E
  777. X};
  778. Xstatic setword    Q27[] = {
  779. X    1,
  780. X    0x000E
  781. X};
  782. Xstatic setword    Q28[] = {
  783. X    1,
  784. X    0x000C
  785. X};
  786. Xstatic setword    Q29[] = {
  787. X    1,
  788. X    0x000E
  789. X};
  790. Xstatic setword    Q30[] = {
  791. X    1,
  792. X    0x000E
  793. X};
  794. Xstatic setword    Q31[] = {
  795. X    2,
  796. X    0x8000,    0x0045
  797. X};
  798. Xstatic setword    Q32[] = {
  799. X    1,
  800. X    0x000E
  801. X};
  802. Xstatic setword    Q33[] = {
  803. X    1,
  804. X    0x000E
  805. X};
  806. Xstatic setword    Q34[] = {
  807. X    3,
  808. X    0x0000,    0x0000,    0x0040
  809. X};
  810. Xstatic setword    Q35[] = {
  811. X    3,
  812. X    0x4010,    0x0C00,    0x000A
  813. X};
  814. Xstatic setword    Q36[] = {
  815. X    5,
  816. X    0x0300,    0x0000,    0x0004,    0x2000,    0x0001
  817. X};
  818. Xstatic setword    Q37[] = {
  819. X    4,
  820. X    0x0300,    0x0000,    0x0004,    0x2000
  821. X};
  822. Xstatic setword    Q38[] = {
  823. X    3,
  824. X    0x0000,    0x0000,    0x0080
  825. X};
  826. Xstatic setword    Q39[] = {
  827. X    4,
  828. X    0x0040,    0x0000,    0x0000,    0x0800
  829. X};
  830. Xstatic setword    Q40[] = {
  831. X    1,
  832. X    0x0040
  833. X};
  834. Xstatic setword    Q41[] = {
  835. X    3,
  836. X    0x0080,    0x0000,    0x0001
  837. X};
  838. Xstatic setword    Q42[] = {
  839. X    4,
  840. X    0x0000,    0x0000,    0x0000,    0x4000
  841. X};
  842. Xstatic setword    Q43[] = {
  843. X    3,
  844. X    0x0000,    0x0000,    0x0800
  845. X};
  846. Xstatic setword    Q44[] = {
  847. X    4,
  848. X    0x0000,    0x0000,    0x0004,    0x2000
  849. X};
  850. Xstatic setword    Q45[] = {
  851. X    1,
  852. X    0x0040
  853. X};
  854. Xstatic setword    Q46[] = {
  855. X    2,
  856. X    0x0000,    0x8000
  857. X};
  858. Xstatic setword    Q47[] = {
  859. X    4,
  860. X    0x0300,    0x0000,    0x0004,    0x2000
  861. X};
  862. Xstatic setword    Q48[] = {
  863. X    4,
  864. X    0x930C,    0x2001,    0x0834,    0x2000
  865. X};
  866. Xstatic setword    Q49[] = {
  867. X    4,
  868. X    0x930C,    0x2001,    0x0834,    0x3000
  869. X};
  870. Xstatic setword    Q50[] = {
  871. X    4,
  872. X    0x0000,    0x0000,    0x0000,    0x1800
  873. X};
  874. Xstatic setword    Q51[] = {
  875. X    2,
  876. X    0x0200,    0x0100
  877. X};
  878. Xstatic setword    Q52[] = {
  879. X    3,
  880. X    0x0200,    0x0100,    0x3C80
  881. X};
  882. Xstatic setword    Q53[] = {
  883. X    2,
  884. X    0x0000,    0x0040
  885. X};
  886. Xstatic setword    Q54[] = {
  887. X    4,
  888. X    0x0000,    0x0000,    0x4FF0,    0x0008
  889. X};
  890. Xstatic setword    Q55[] = {
  891. X    4,
  892. X    0x03E1,    0x80CA,    0xF005,    0xBFFE
  893. X};
  894. Xstatic setword    Q56[] = {
  895. X    4,
  896. X    0x0000,    0x0030,    0x3F80,    0x001A
  897. X};
  898. Xstatic setword    Q57[] = {
  899. X    4,
  900. X    0x0000,    0x0000,    0x0000,    0x0478
  901. X};
  902. Xstatic setword    Q58[] = {
  903. X    4,
  904. X    0x0000,    0x0000,    0x0000,    0x0478
  905. X};
  906. Xstatic setword    Q59[] = {
  907. X    1,
  908. X    0x0C0C
  909. X};
  910. Xstatic setword    Q60[] = {
  911. X    3,
  912. X    0x0000,    0x0000,    0x0800
  913. X};
  914. Xstatic setword    Q61[] = {
  915. X    5,
  916. X    0x0000,    0x0000,    0x0000,    0x000B,    0x0001
  917. X};
  918. Xstatic setword    Q62[] = {
  919. X    5,
  920. X    0x03E1,    0x80CA,    0xF005,    0xFFFF,    0x0001
  921. X};
  922. Xstatic setword    Q63[] = {
  923. X    4,
  924. X    0x930C,    0x2001,    0x0834,    0x2000
  925. X};
  926. Xstatic setword    Q64[] = {
  927. X    4,
  928. X    0x0000,    0x0000,    0x0000,    0x1000
  929. X};
  930. Xstatic setword    Q65[] = {
  931. X    4,
  932. X    0x930C,    0x2001,    0x08B4,    0x2000
  933. X};
  934. Xstatic setword    Q66[] = {
  935. X    4,
  936. X    0x0000,    0x0000,    0x0000,    0x2004
  937. X};
  938. Xstatic setword    Q67[] = {
  939. X    3,
  940. X    0x0000,    0x0000,    0x0800
  941. X};
  942. Xstatic setword    Q68[] = {
  943. X    4,
  944. X    0x0000,    0x0000,    0x0000,    0x1000
  945. X};
  946. Xstatic setword    Q69[] = {
  947. X    4,
  948. X    0x0000,    0x0000,    0x0000,    0x1002
  949. X};
  950. Xstatic setword    Q70[] = {
  951. X    4,
  952. X    0x0000,    0x0000,    0x0000,    0x2004
  953. X};
  954. Xstatic setword    Q71[] = {
  955. X    4,
  956. X    0x0000,    0x0000,    0x0000,    0x2006
  957. X};
  958. Xstatic setword    Q72[] = {
  959. X    4,
  960. X    0x0000,    0x0000,    0x0000,    0x2004
  961. X};
  962. Xstatic setword    Q73[] = {
  963. X    3,
  964. X    0x0002,    0x0000,    0x0800
  965. X};
  966. Xstatic setword    Q74[] = {
  967. X    3,
  968. X    0x0000,    0x0000,    0x0800
  969. X};
  970. Xstatic setword    Q75[] = {
  971. X    4,
  972. X    0x0000,    0x0000,    0x0000,    0x1000
  973. X};
  974. Xstatic setword    Q76[] = {
  975. X    3,
  976. X    0x0000,    0x0000,    0x0800
  977. X};
  978. Xstatic setword    Q77[] = {
  979. X    3,
  980. X    0x4000,    0x0400,    0x0808
  981. X};
  982. Xstatic setword    Q78[] = {
  983. X    3,
  984. X    0x0002,    0x0000,    0x0800
  985. X};
  986. Xstatic setword    Q79[] = {
  987. X    2,
  988. X    0x0000,    0x0040
  989. X};
  990. Xstatic setword    Q80[] = {
  991. X    4,
  992. X    0x0000,    0x0000,    0x0000,    0x2010
  993. X};
  994. Xstatic setword    Q81[] = {
  995. X    3,
  996. X    0x0000,    0x0000,    0x0800
  997. X};
  998. Xstatic setword    Q82[] = {
  999. X    4,
  1000. X    0x0000,    0x0000,    0x0000,    0x2010
  1001. X};
  1002. Xstatic setword    Q83[] = {
  1003. X    3,
  1004. X    0x0000,    0x0000,    0x0800
  1005. X};
  1006. Xstatic setword    Q84[] = {
  1007. X    4,
  1008. X    0x0000,    0x0000,    0x0000,    0x0008
  1009. X};
  1010. Xstatic setword    Q85[] = {
  1011. X    4,
  1012. X    0x0000,    0x0000,    0x0000,    0x1000
  1013. X};
  1014. Xstatic setword    Q86[] = {
  1015. X    3,
  1016. X    0x0000,    0x0000,    0x0800
  1017. X};
  1018. Xstatic setword    Q87[] = {
  1019. X    4,
  1020. X    0x0000,    0x0000,    0x0000,    0x8000
  1021. X};
  1022. Xstatic setword    Q88[] = {
  1023. X    3,
  1024. X    0x0000,    0x0000,    0x0800
  1025. X};
  1026. Xstatic setword    Q89[] = {
  1027. X    3,
  1028. X    0x4004,    0x0400,    0x0040
  1029. X};
  1030. Xstatic setword    Q90[] = {
  1031. X    4,
  1032. X    0x0000,    0x0000,    0x0000,    0x2000
  1033. X};
  1034. Xstatic setword    Q91[] = {
  1035. X    1,
  1036. X    0x2400
  1037. X};
  1038. Xstatic setword    Q92[] = {
  1039. X    3,
  1040. X    0x4014,    0x0404,    0x000A
  1041. X};
  1042. Xstatic setword    Q93[] = {
  1043. X    4,
  1044. X    0x0000,    0x0000,    0x0000,    0x2000
  1045. X};
  1046. Xstatic setword    Q94[] = {
  1047. X    3,
  1048. X    0x6414,    0x0404,    0x000A
  1049. X};
  1050. Xstatic setword    Q95[] = {
  1051. X    4,
  1052. X    0x0000,    0x0000,    0x0000,    0x2000
  1053. X};
  1054. Xstatic setword    Q96[] = {
  1055. X    3,
  1056. X    0x0000,    0x0000,    0x0800
  1057. X};
  1058. Xstatic setword    Q97[] = {
  1059. X    3,
  1060. X    0x0000,    0x0000,    0x0800
  1061. X};
  1062. Xstatic setword    Q98[] = {
  1063. X    3,
  1064. X    0x4004,    0x0400,    0x0840
  1065. X};
  1066. Xstatic setword    Q99[] = {
  1067. X    4,
  1068. X    0x0000,    0x0000,    0x0000,    0x1800
  1069. X};
  1070. Xstatic setword    Q100[] = {
  1071. X    3,
  1072. X    0x0000,    0x0000,    0x0800
  1073. X};
  1074. Xstatic setword    Q101[] = {
  1075. X    4,
  1076. X    0x0000,    0x0000,    0x0000,    0x1800
  1077. X};
  1078. Xstatic setword    Q102[] = {
  1079. X    3,
  1080. X    0x0000,    0x0000,    0x0800
  1081. X};
  1082. Xstatic setword    Q103[] = {
  1083. X    3,
  1084. X    0x4004,    0x0400,    0x0848
  1085. X};
  1086. Xstatic setword    Q104[] = {
  1087. X    4,
  1088. X    0x0000,    0x0000,    0x0000,    0x0020
  1089. X};
  1090. Xstatic setword    Q105[] = {
  1091. X    3,
  1092. X    0x0000,    0x0000,    0x0800
  1093. X};
  1094. Xstatic setword    Q106[] = {
  1095. X    2,
  1096. X    0x0000,    0x0040
  1097. X};
  1098. Xstatic setword    Q107[] = {
  1099. X    2,
  1100. X    0x0000,    0x0040
  1101. X};
  1102. Xstatic setword    Q108[] = {
  1103. X    4,
  1104. X    0x0000,    0x0000,    0x0000,    0x0010
  1105. X};
  1106. Xstatic setword    Q109[] = {
  1107. X    4,
  1108. X    0x0000,    0x0000,    0x0000,    0x0008
  1109. X};
  1110. Xstatic setword    Q110[] = {
  1111. X    4,
  1112. X    0x0200,    0x0000,    0x0000,    0x2004
  1113. X};
  1114. Xstatic setword    Q111[] = {
  1115. X    3,
  1116. X    0x0000,    0x0000,    0x0800
  1117. X};
  1118. Xstatic setword    Q112[] = {
  1119. X    4,
  1120. X    0x0000,    0x0000,    0x0000,    0x0004
  1121. X};
  1122. Xstatic setword    Q113[] = {
  1123. X    3,
  1124. X    0x0000,    0x0000,    0x0800
  1125. X};
  1126. Xstatic setword    Q114[] = {
  1127. X    3,
  1128. X    0x0000,    0x0000,    0x3C80
  1129. X};
  1130. Xstatic setword    Q115[] = {
  1131. X    4,
  1132. X    0x0000,    0x0000,    0x0000,    0x8000
  1133. X};
  1134. Xstatic setword    Q116[] = {
  1135. X    4,
  1136. X    0x0000,    0x0000,    0x0000,    0x8000
  1137. X};
  1138. Xstatic setword    Q117[] = {
  1139. X    4,
  1140. X    0x0200,    0x0000,    0x0000,    0x2814
  1141. X};
  1142. Xstatic setword    Q118[] = {
  1143. X    2,
  1144. X    0x0802,    0x5000
  1145. X};
  1146. Xstatic setword    Q119[] = {
  1147. X    4,
  1148. X    0x0802,    0x5200,    0x3C80,    0x0003
  1149. X};
  1150. Xstatic setword    Q120[] = {
  1151. X    4,
  1152. X    0x0200,    0x0000,    0x0000,    0x2004
  1153. X};
  1154. Xstatic setword    Q121[] = {
  1155. X    4,
  1156. X    0x0000,    0x0000,    0x0000,    0x0002
  1157. X};
  1158. Xstatic setword    Q122[] = {
  1159. X    4,
  1160. X    0x0000,    0x0000,    0x0000,    0x1800
  1161. X};
  1162. Xstatic setword    Q123[] = {
  1163. X    3,
  1164. X    0x0000,    0x0000,    0x3C80
  1165. X};
  1166. Xstatic setword    Q124[] = {
  1167. X    2,
  1168. X    0x0000,    0x0040
  1169. X};
  1170. Xstatic setword    Q125[] = {
  1171. X    3,
  1172. X    0x0000,    0x0000,    0x0800
  1173. X};
  1174. Xstatic setword    Q126[] = {
  1175. X    4,
  1176. X    0x0000,    0x0040,    0x0000,    0x1000
  1177. X};
  1178. Xstatic setword    Q127[] = {
  1179. X    3,
  1180. X    0x0000,    0x0000,    0x0800
  1181. X};
  1182. Xstatic setword    Q128[] = {
  1183. X    3,
  1184. X    0x0008,    0x0000,    0x0800
  1185. X};
  1186. Xstatic setword    Q129[] = {
  1187. X    4,
  1188. X    0x0000,    0x0000,    0x0000,    0x1000
  1189. X};
  1190. Xstatic setword    Q130[] = {
  1191. X    3,
  1192. X    0x0008,    0x0000,    0x0800
  1193. X};
  1194. Xstatic setword    Q131[] = {
  1195. X    3,
  1196. X    0x0000,    0x0000,    0x0880
  1197. X};
  1198. Xstatic setword    Q132[] = {
  1199. X    3,
  1200. X    0x0000,    0x0000,    0x0980
  1201. X};
  1202. Xstatic setword    Q133[] = {
  1203. X    3,
  1204. X    0x0000,    0x0000,    0x3000
  1205. X};
  1206. Xstatic setword    Q134[] = {
  1207. X    3,
  1208. X    0x4004,    0x0400,    0x084A
  1209. X};
  1210. Xstatic setword    Q135[] = {
  1211. X    4,
  1212. X    0x0000,    0x0000,    0x0000,    0x2000
  1213. X};
  1214. Xstatic setword    Q136[] = {
  1215. X    3,
  1216. X    0x0000,    0x0000,    0x3F80
  1217. X};
  1218. Xstatic setword    Q137[] = {
  1219. X    4,
  1220. X    0x0000,    0x0000,    0x0000,    0x0020
  1221. X};
  1222. Xstatic setword    Q138[] = {
  1223. X    3,
  1224. X    0x0000,    0x0000,    0x0800
  1225. X};
  1226. Xstatic setword    Q139[] = {
  1227. X    4,
  1228. X    0x0000,    0x0000,    0x0000,    0x1824
  1229. X};
  1230. Xstatic setword    Q140[] = {
  1231. X    3,
  1232. X    0x0000,    0x0000,    0x0800
  1233. X};
  1234. Xstatic setword    Q141[] = {
  1235. X    4,
  1236. X    0x0000,    0x0000,    0x0000,    0x1824
  1237. X};
  1238. Xstatic setword    Q142[] = {
  1239. X    3,
  1240. X    0x4014,    0x0400,    0x000A
  1241. X};
  1242. Xstatic setword    Q143[] = {
  1243. X    4,
  1244. X    0x0000,    0x0000,    0x0000,    0x2800
  1245. X};
  1246. Xstatic setword    Q144[] = {
  1247. X    3,
  1248. X    0x0000,    0x0000,    0x0080
  1249. X};
  1250. Xstatic setword    Q145[] = {
  1251. X    4,
  1252. X    0x0000,    0x0000,    0x0000,    0x2000
  1253. X};
  1254. Xstatic setword    Q146[] = {
  1255. X    5,
  1256. X    0x0000,    0x0000,    0x0000,    0x0000,    0x0001
  1257. X};
  1258. Xstatic setword    Q147[] = {
  1259. X    3,
  1260. X    0x4014,    0x0404,    0x000A
  1261. X};
  1262. Xstatic setword    Q148[] = {
  1263. X    4,
  1264. X    0x0000,    0x0000,    0x0000,    0x2000
  1265. X};
  1266. Xstatic setword    Q149[] = {
  1267. X    3,
  1268. X    0x0000,    0x0000,    0x0800
  1269. X};
  1270. Xstatic setword    Q150[] = {
  1271. X    4,
  1272. X    0x0000,    0x0000,    0x0000,    0x2002
  1273. X};
  1274. Xstatic setword    Q151[] = {
  1275. X    3,
  1276. X    0x0000,    0x0000,    0x0800
  1277. X};
  1278. Xstatic setword    Q152[] = {
  1279. X    4,
  1280. X    0x0000,    0x0000,    0x0000,    0x0804
  1281. X};
  1282. Xstatic setword    Q153[] = {
  1283. X    3,
  1284. X    0x0000,    0x0000,    0x0800
  1285. X};
  1286. Xstatic setword    Q154[] = {
  1287. X    4,
  1288. X    0x0000,    0x0000,    0x0000,    0x0804
  1289. X};
  1290. Xstatic setword    Q155[] = {
  1291. X    3,
  1292. X    0x0000,    0x0000,    0x0800
  1293. X};
  1294. Xstatic setword    Q156[] = {
  1295. X    4,
  1296. X    0x0000,    0x0000,    0x0000,    0x0804
  1297. X};
  1298. Xstatic setword    Q157[] = {
  1299. X    3,
  1300. X    0x0004,    0x0000,    0x0040
  1301. X};
  1302. Xstatic setword    Q158[] = {
  1303. X    1,
  1304. X    0x0018
  1305. X};
  1306. Xstatic setword    Q159[] = {
  1307. X    1,
  1308. X    0x00C0
  1309. X};
  1310. Xstatic setword    Q160[] = {
  1311. X    1,
  1312. X    0x001A
  1313. X};
  1314. Xstatic setword    Q161[] = {
  1315. X    1,
  1316. X    0x001E
  1317. X};
  1318. Xstatic setword    Q162[] = {
  1319. X    1,
  1320. X    0x001F
  1321. X};
  1322. Xstatic setword    Q163[] = {
  1323. X    1,
  1324. X    0x1FE7
  1325. X};
  1326. Xstatic setword    *Conset[] = {
  1327. X    Q163,    Q162,    Q161,
  1328. X    Q160,    Q159,    Q158,    Q157,    Q156,    Q155,
  1329. X    Q154,    Q153,    Q152,    Q151,    Q150,    Q149,
  1330. X    Q148,    Q147,    Q146,    Q145,    Q144,    Q143,
  1331. X    Q142,    Q141,    Q140,    Q139,    Q138,    Q137,
  1332. X    Q136,    Q135,    Q134,    Q133,    Q132,    Q131,
  1333. X    Q130,    Q129,    Q128,    Q127,    Q126,    Q125,
  1334. X    Q124,    Q123,    Q122,    Q121,    Q120,    Q119,
  1335. X    Q118,    Q117,    Q116,    Q115,    Q114,    Q113,
  1336. X    Q112,    Q111,    Q110,    Q109,    Q108,    Q107,
  1337. X    Q106,    Q105,    Q104,    Q103,    Q102,    Q101,
  1338. X    Q100,    Q99,    Q98,    Q97,    Q96,    Q95,
  1339. X    Q94,    Q93,    Q92,    Q91,    Q90,    Q89,
  1340. X    Q88,    Q87,    Q86,    Q85,    Q84,    Q83,
  1341. X    Q82,    Q81,    Q80,    Q79,    Q78,    Q77,
  1342. X    Q76,    Q75,    Q74,    Q73,    Q72,    Q71,
  1343. X    Q70,    Q69,    Q68,    Q67,    Q66,    Q65,
  1344. X    Q64,    Q63,    Q62,    Q61,    Q60,    Q59,
  1345. X    Q58,    Q57,    Q56,    Q55,    Q54,    Q53,
  1346. X    Q52,    Q51,    Q50,    Q49,    Q48,    Q47,
  1347. X    Q46,    Q45,    Q44,    Q43,    Q42,    Q41,
  1348. X    Q40,    Q39,    Q38,    Q37,    Q36,    Q35,
  1349. X    Q34,    Q33,    Q32,    Q31,    Q30,    Q29,
  1350. X    Q28,    Q27,    Q26,    Q25,    Q24,    Q23,
  1351. X    Q22,    Q21,    Q20,    Q19,    Q18,    Q17,
  1352. X    Q16,    Q15,    Q14,    Q13,    Q12,    Q11,
  1353. X    Q10,    Q9,    Q8,    Q7,    Q6,    Q5,
  1354. X    Q4,    Q3,    Q2,    Q1,    Q0
  1355. X};
  1356. X
  1357. Xstatic setptr
  1358. XUnion(p1, p2)
  1359. X    register setptr    p1, p2;
  1360. X{
  1361. X    register int        i, j, k;
  1362. X    register setptr        sp = Newset(),
  1363. X                p3 = sp;
  1364. X
  1365. X    j = *p1;
  1366. X    *p3 = j;
  1367. X    if (j > *p2)
  1368. X        j = *p2;
  1369. X    else
  1370. X        *p3 = *p2;
  1371. X    k = *p1 - *p2;
  1372. X    p1++, p2++, p3++;
  1373. X    for (i = 0; i < j; i++)
  1374. X        *p3++ = (*p1++ | *p2++);
  1375. X    while (k > 0) {
  1376. X        *p3++ = *p1++;
  1377. X        k--;
  1378. X    }
  1379. X    while (k < 0) {
  1380. X        *p3++ = *p2++;
  1381. X        k++;
  1382. X    }
  1383. X    return (Saveset(sp));
  1384. X}
  1385. X
  1386. Xstatic boolean
  1387. XMember(m, sp)
  1388. X    register unsigned int    m;
  1389. X    register setptr    sp;
  1390. X{
  1391. X    register unsigned int    i = m / (setbits+1) + 1;
  1392. X
  1393. X    if ((i <= *sp) && (sp[i] & (1 << (m % (setbits+1)))))
  1394. X        return (true);
  1395. X    return (false);
  1396. X}
  1397. X
  1398. Xstatic setptr
  1399. XInsmem(m, sp)
  1400. X    register unsigned int    m;
  1401. X    register setptr    sp;
  1402. X{
  1403. X    register int    i,
  1404. X                j = m / (setbits+1) + 1;
  1405. X
  1406. X    if (*sp < j)
  1407. X        for (i = *sp + 1, *sp = j; i <= *sp; i++)
  1408. X            sp[i] = 0;
  1409. X    sp[j] |= (1 << (m % (setbits+1)));
  1410. X    return (sp);
  1411. X}
  1412. X
  1413. X# ifndef SETSPACE
  1414. X# define SETSPACE 256
  1415. X# endif
  1416. Xstatic setptr
  1417. XCurrset(n,sp)
  1418. X    int    n;
  1419. X    setptr    sp;
  1420. X{
  1421. X    static setword    Space[SETSPACE];
  1422. X    static setptr    Top = Space;
  1423. X
  1424. X    switch (n) {
  1425. X      case 0:
  1426. X        Top = Space;
  1427. X        return (0);
  1428. X      case 1:
  1429. X        if (&Space[SETSPACE] - Top <= 15) {
  1430. X            (void)fprintf(stderr, "Set-space exhausted\n");
  1431. X            exit(1);
  1432. X        }
  1433. X        *Top = 0;
  1434. X        return (Top);
  1435. X      case 2:
  1436. X        if (Top <= &sp[*sp])
  1437. X            Top = &sp[*sp + 1];
  1438. X        return (sp);
  1439. X    }
  1440. X    /* NOTREACHED */
  1441. X}
  1442. X
  1443. Xstatic void
  1444. XSetncpy(S1, S2, N)
  1445. X    register setptr    S1, S2;
  1446. X    register unsigned int    N;
  1447. X{
  1448. X    register unsigned int    m;
  1449. X
  1450. X    N /= sizeof(setword);
  1451. X    *S1++ = --N;
  1452. X    m = *S2++;
  1453. X    while (m != 0 && N != 0) {
  1454. X        *S1++ = *S2++;
  1455. X        --N;
  1456. X        --m;
  1457. X    }
  1458. X    while (N-- != 0)
  1459. X        *S1++ = 0;
  1460. X}
  1461. X
  1462. Xstatic void
  1463. XCaseerror(n)
  1464. X    int    n;
  1465. X{
  1466. X    (void)fprintf(stderr, "Missing case limb: line %d\n", n);
  1467. X    exit(1);
  1468. X}
  1469. X
  1470. END_OF_FILE
  1471. if test 28856 -ne `wc -c <'ptc.c.7'`; then
  1472.     echo shar: \"'ptc.c.7'\" unpacked with wrong size!
  1473. fi
  1474. # end of 'ptc.c.7'
  1475. fi
  1476. if test -f 'ptc.man' -a "${1}" != "-c" ; then 
  1477.   echo shar: Will not clobber existing file \"'ptc.man'\"
  1478. else
  1479. echo shar: Extracting \"'ptc.man'\" \(2583 characters\)
  1480. sed "s/^X//" >'ptc.man' <<'END_OF_FILE'
  1481. XFrom enea!holtec!perb Sat May  9 17:47:50 1987
  1482. XReceived: by mirror.TMC.COM; Sat, 9 May 87 17:47:37 edt
  1483. XReceived: from enea.UUCP by seismo.CSS.GOV (5.54/1.14) with UUCP 
  1484. X    id AA12891; Sat, 9 May 87 16:51:27 EDT
  1485. XReceived: by enea.se (5.51/1.33)
  1486. X    id AA18863; Sat, 9 May 87 22:36:30 +0200 (MET)
  1487. XReceived: by chalmers.UUCP id AA22220; Sat, 9 May 87 22:08:11 -0200
  1488. XReceived: by holtec.uucp (2.0/SMI-2.0)
  1489. X    id AA12513; Sat, 9 May 87 21:24:27 -0200
  1490. XDate: Sat, 9 May 87 21:24:27 -0200
  1491. XFrom: enea!holtec!perb (Per Bergsten)
  1492. XMessage-Id: <8705091924.AA12513@holtec.uucp>
  1493. XTo: mirror!sources
  1494. XStatus: R
  1495. X
  1496. XSubject: ptc.man
  1497. X.\"        @(#)ptc.man    1.3 Date 87/05/09
  1498. X.if \nP .pl \nP
  1499. X.TH PTC 1
  1500. X.SH NAME
  1501. Xptc \- Pascal to C translator
  1502. X.SH SYNOPSIS
  1503. X.B ptc
  1504. X< pascal\ source > c\ source
  1505. X.SH DESCRIPTION
  1506. X.I Ptc
  1507. Xreads a correct Pascal program and prints a C program with
  1508. Xthe same behaviour.
  1509. XIt is intended as a tool for transporting finished applications to
  1510. Xenvironments that lack Pascal compilers,
  1511. Xit is
  1512. X.I not
  1513. Xintended for program development.
  1514. X.PP
  1515. XThe input should comply with the ISO level 0 Pascal definition.
  1516. XTwo common Pascal extensions are also recognized: the keyword
  1517. X.B otherwise
  1518. Xmay be used for default entries in case-statements,
  1519. Xthe keyword
  1520. X.B external
  1521. Xmay be used in place of the forward directive to signify that
  1522. Xa procedure or function is defined in a library.
  1523. XFurthermore,
  1524. Xthe translator does not require a complete Pascal program,
  1525. Xa consistent subset of declarations can be translated.
  1526. XThus a primitive module concept is supported.
  1527. X.SH "SEE ALSO"
  1528. XPtc implementation notes.
  1529. X.SH CAVEATS
  1530. XThe quality of an object program is of course highly dependent on the
  1531. XC compiler that processes the translated code.
  1532. XArithmetic operations are sometimes implemented in a way that is incompatible
  1533. Xwith the Pascal definition.
  1534. XFor example, the translator assumes that:
  1535. X.sp
  1536. X.nf
  1537. X    a := b mod c
  1538. X.fi
  1539. X.sp
  1540. Xcan be accurately translated into
  1541. X.sp
  1542. X.nf
  1543. X    a = b % c
  1544. X.fi
  1545. X.sp
  1546. Xbut that may not be true if c is negative.
  1547. XA check on the characteristics of integer and float arithmetic is
  1548. Xstrongly recommended.
  1549. X.PP
  1550. XSome Pascal constructs are impossible to express in C.
  1551. XThe translator will not object to:
  1552. X.sp
  1553. X.nf
  1554. X    type    ptr = ^ ptr;
  1555. X.fi
  1556. X.sp
  1557. Xbut a C-compiler may balk at the resulting:
  1558. X.sp
  1559. X.nf
  1560. X    typedef    ptr * ptr;
  1561. X.fi
  1562. X.sp
  1563. X.SH BUGS
  1564. XThe program can't translate comments from Pascal to C.
  1565. X.sp
  1566. XThe translator does not do complete typechecking so
  1567. Xa Pascal program that isn't formally correct may cause malfunction.
  1568. X.sp
  1569. XPassing a procedure as parameter to an enclosing recursive procedure
  1570. Xmay produce erroneous code (see the implementation notes).
  1571. X
  1572. END_OF_FILE
  1573. if test 2583 -ne `wc -c <'ptc.man'`; then
  1574.     echo shar: \"'ptc.man'\" unpacked with wrong size!
  1575. fi
  1576. # end of 'ptc.man'
  1577. fi
  1578. echo shar: End of archive 1 \(of 12\).
  1579. cp /dev/null ark1isdone
  1580. MISSING=""
  1581. for I in 1 2 3 4 5 6 7 8 9 10 11 12 ; do
  1582.     if test ! -f ark${I}isdone ; then
  1583.     MISSING="${MISSING} ${I}"
  1584.     fi
  1585. done
  1586. if test "${MISSING}" = "" ; then
  1587.     echo You have unpacked all 12 archives.
  1588.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1589. else
  1590.     echo You still need to unpack the following archives:
  1591.     echo "        " ${MISSING}
  1592. fi
  1593. ##  End of shell archive.
  1594. exit 0
  1595. -- 
  1596.  
  1597. Rich $alz            "Anger is an energy"
  1598. Cronus Project, BBN Labs    rsalz@bbn.com
  1599. Moderator, comp.sources.unix    sources@uunet.uu.net
  1600.